#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>
#include <string.h>

int main() {
    int i, n;
    int sz;
    int flag[3];
    scanf("%d", &n);
    while (n--)
    {
        char ch[101] = { '\0' };
        scanf("%s", ch);
        sz =strlen(ch);
        if ((ch[0] < '0' && ch[0]>'9') || sz < 8)
        {
            printf("NO\n");
            continue;
        }
        for (i = 0; i < sz; i++)
        {
            if ((ch[i] > '0' && ch[i] < '9') || (ch[i] > 'A' && ch[i] < 'z'))
            {
                if (ch[i] > '0' && ch[i] < '9')
                    flag[0] = 1;
                if (ch[i] > 'A' && ch[i] < 'Z')
                    flag[1] = 1;
                if (ch[i] > 'a' && ch[i] < 'z')
                    flag[2] = 1;
            }
        }
        if (2 <= flag[0] + flag[1] + flag[2])
            printf("YES\n");
        else
            printf("NO\n");
    }

    return 0;
}


